<?php namespace app\admin\controller;

use houdunwang\request\Request;
use houdunwang\route\Controller;
use system\model\Config as ConfigModel;

class Config extends Common
{

    public function setting(ConfigModel $config)
    {

        if (IS_POST) {
//            p(Request::post());die;
            $config->setConfig(Request::post());
            return $this->setRedirect('refresh')->success('操作成功');
        }
        //获取数据库的数据

        $model = ConfigModel::find(1);
//
//        无数据时默认给空数组
        $field = $model ? json_decode($model['system'],true): [];
        return view('',compact('field'));
    }
}
